const db=wx.cloud.database()
var app=getApp()
Page({
  data: {array: ['上海', '北京', '杭州', '宁波'],
  index: 0,
    curIndex :0,
   list:[],
   list1:[],
   list2:[],
   list3:[],
   swiper:[],
   category:[],
   noticeList: [
    {id:0, title:"自产自销，做回头客生意，无中间商赚差价"},
    {id:1, title:"品质保证,无机肥,味道很鲜甜"},
    {id:2, title:""},
   
  ],
  isEnd: false, 
  },
  // 收货地址bindtap
  bindPickerChange: function (e) {
    this.setData({
      index: e.detail.value
    })
  },
  // 轮播图的Tap
  swiperTap:function(e){
    console.log("这是首页点击icon的id噢：",e.currentTarget.dataset.id)
    getApp().globalData.cate_id = e.currentTarget.dataset.id
    var id=e.currentTarget.dataset.id
    if(id == 0){
      getApp().globalData.cate_id = 0
      wx.navigateTo({
       url:"../fruit/fruit"
      })}
        var that = this;
          console.log(e.currentTarget.dataset.swiper)
          var id=e.currentTarget.dataset.swiper.id
          var swiper=e.currentTarget.dataset.swiper
         var detail_01=e.currentTarget.dataset.swiper.detail_01
          var swiper_dict = JSON.stringify(swiper)
         if(id==1){
          wx.navigateTo({
            url: '../maguo_detail/maguo_detail?swiper='+swiper_dict
          })
         }
         if(id==2){
          wx.navigateTo({
            url: '../LiZhi_detial/LiZhi_detial?swiper='+swiper_dict
          })
         }
         if(id==3){
          wx.navigateTo({
            url: '../Banana_detail/Banana_detail?swiper='+swiper_dict
          })
         }
  },
  // 推荐bindtap
  Tap:function(e){
        console.log(e.currentTarget.dataset)
          var id=e.currentTarget.dataset.id
      if(id==0){
        wx.navigateTo({
          url: '../HongPingGuo_detail/HongPingGuo_detail',
        })
      }
      if(id==1){
        wx.navigateTo({
          url: '../LiuLian_detail/LiuLian_detail',
        })
      }
      if(id==2){
        wx.navigateTo({
          url: '../FanShiLiu_detail/FanShiLiu_detail',
        })
      }
  },
  //  鲜果bindtap
  listTap:function(e){
     console.log(e.currentTarget.dataset)
          var id=e.currentTarget.dataset.id
      if(id==0){
        wx.navigateTo({
          url: '../MiHouTao_detail/MiHouTao_detail',
        })
      }
      if(id==1){
        wx.navigateTo({
          url: '../LanMei_detail/LanMei_detail',
        })
      }
      if(id==2){
        wx.navigateTo({
          url: '../LongYan_detail/LongYan_detail',
        })
      }
  },
  // 特产bindtap
  EndTap:function(e){
    console.log(e.currentTarget.dataset)
          var id=e.currentTarget.dataset.id
      if(id==0){
        wx.navigateTo({
          url: '../HouLongGuo_detail/HouLongGuo_detail',
        })
      }
      if(id==1){
        wx.navigateTo({
          url: '../LiZi_detail/LiZi_detail',
        })
      }
      if(id==2){
        wx.navigateTo({
          url: '../Chengzi_detail/Chengzi_detail',
        })
      }
  },
  // <!-- 顶部标签栏 Tap-->
  textTap:function(e){
    const{index}=e.currentTarget.dataset;
    this.setData({
      curIndex:index
    })
    if(index==1){
      wx.navigateTo({
        url: '../fruit/fruit',
      })
    }
    if(index==2){
      wx.switchTab({
        url:"../shop/shop"
      })
    }
  },
  GetDate:function(e){
    db.collection('Swiper').get({
      success:res=>{
        console.log(res.data[0].list)
        console.log(res.data[0].swiper)
        console.log(res.data[0].list1)
        console.log(res.data[0].list2)
        console.log(res.data[0].category)
        console.log(res.data[0].list3)
        this.setData({swiper:res.data[0].swiper,
          list:res.data[0].list,
          list3:res.data[0].list3,
          list2:res.data[0].list2,
          list1:res.data[0].list1,
          category:res.data[0].category})
      }
     })
   
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.  GetDate()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})